<!DOCTYPE html>
<html xmlns=http://www.w3.org/1999/xhtml xmlns:bd=http://www.baidu.com/2010/xbdml>
<head>
    <meta http-equiv="Content-Type" content="text/html" charset="utf-8">
    <title>员工列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link Rel="SHORTCUT ICON" href="/pc/login/img/logo1.png">
    <link rel="stylesheet" href="/pc/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/pc/layout/css/font_eolqem241z66flxr.css" media="all" />
    <link rel="stylesheet" href="/pc/layout/css/news.css" media="all" />
    <script type="text/javascript" src="/pc/layout/js/jquery.min.js"></script>
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote news_search">
    <form class="layui-form" id="form" action="/admin/user/index" method="get">
        @if($areaids ==="0")
            <div class="layui-input-inline" style="margin-top: 5px;margin-right: 20px;">
                <label class="layui-form-label" style="padding: 0;width: 66px;height: 38px;background: #E5E5E5;text-align: center;line-height: 38px;border-radius: 2px;">代理商</label>
                <div class="layui-input-block" style="width: 15em;margin-left: 66px">
                    <select name="agent_id" lay-verify="required" lay-search="">
                        <option value="">请选择代理商</option>
                        @if(!empty($agentInfo))
                            @foreach($agentInfo as $v)
                                <option value="{{$v['id']}}" @if($v['id'] == $get['agent_id']) selected @endif>{{$v['name']}}</option>
                            @endforeach
                        @endif
                    </select>
                </div>
            </div>
        @endif
         <div class="layui-input-inline" style="margin-top: 5px; margin-right:20px;">        
            <label class="layui-form-label" style="padding: 0;width: 66px;height: 38px;background: #E5E5E5;text-align: center;line-height: 38px;border-radius: 2px;">用户名</label>
            <input type="text" name="name" value="{{$get['name']}}" placeholder="请输入用户名" class="layui-input search_input" style="width: 11em">
        </div>
        <div class="layui-input-inline" style="margin-top: 5px; margin-right:20px;">        
            <label class="layui-form-label" style="padding: 0;width: 66px;height: 38px;background: #E5E5E5;text-align: center;line-height: 38px;border-radius: 2px;">手 机号</label>
            <input type="text" name="phone" value="{{$get['phone']}}" placeholder="请输入手机号" class="layui-input search_input" style="width: 11em">
        </div>
        <div class="layui-input-inline" style="margin-top: 5px; margin-right:20px;">        
            <label class="layui-form-label" style="padding: 0;width: 66px;height: 38px;background: #E5E5E5;text-align: center;line-height: 38px;border-radius: 2px;">邮箱</label>
            <input type="text" name="email" value="{{$get['email']}}" placeholder="请输入邮箱" class="layui-input search_input" style="width: 11em">
        </div>
       <div class="layui-input-inline" style="">
        <a class="layui-btn search_btn" style="margin-top: 5px;" id="inqe">查询</a>
         <a class="layui-btn linksAdd_btn" style="background-color:#161917;margin-top: 5px;">添加</a>
        </div>
          <script>
            $('#inqe').click(function () {
                $('#form').submit();
            })
        </script>
    </form>
</blockquote>
<div class="layui-form links_list">
    <table class="layui-table">
         {{csrf_field()}}
        <thead>
        <tr>
            <th>用户编号</th>
            <th>用户名称</th>
            <th>管理范围</th>
            <th>手机号</th>
            <th>邮箱</th>            
            <th>操作</th>
        </tr>
        </thead>
        <tbody class="links_content">
        @if($data)
            @foreach($data as $val)
                <tr id="staff_{{$val['id']}}">
                    <td>{{$val['id']}}</td>
                    <td>{{$val['name']}}</td>
                    <td>
                        @if($val['range']['area'] != '')
                            区域:{{$val['range']['area']}}
                        @endif
                    </td>
                    <td>{{$val['phone']}}</td>
                    <td>{{$val['email']}}</td>
                    <td
                    ><a class="layui-btn layui-btn-mini links_edit" staff="{{$val['id']}}" ><i class="iconfont icon-edit"></i> 编辑</a>
                        <a class="layui-btn layui-btn-danger layui-btn-mini links_del" data-id="1" onclick="delStaff({{$val['id']}})"><i class="layui-icon"></i> 删除</a>
                    </td>
                </tr>
            @endforeach
        @endif
        </tbody>
    </table>
</div>
@if(!null == $info)
    <div style="float:right;">
        {!! $info->appends($request)->render() !!}
    </div>
@endif

<script type="text/javascript" src="/pc/layui/layui.js"></script>
<script type="text/javascript" src="/pc/staff/js/staff.js"></script>
<script>
         function delStaff(id){  //删除
        layer.confirm('确定删除此信息？',{icon:3, title:'提示信息'},function(index){
            $.ajax({
                url:'/admin/staff/destroy',
                type:'post',
                async:false,
                data:{
                    "_token": $("input[name=_token]").val(),
                    'id':id
                },
                dataType:'json',
                success:function (data) {
                    if(data.status == 1){
                        $('#staff_'+id).remove();
                        layer.msg('删除成功！',{time:800});
                         // parent.location.reload();
                         layer.close(index);
                    }else{
                    top.layer.close(index);
                    top.layer.msg("删除失败！");
                }
                }
            })
            layer.close(index);
        });
    }
</script>
</body>
</html>